package com.dianxin.smartpark.web.common;

import java.util.List;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.alibaba.fastjson.JSON;
import com.chinatelecom.response.common.CommonResponseBody;
import com.chinatelecom.response.utils.ResponseBodyWrapperUtil;
import com.dianxin.smartpark.dao.qo.common.SmartParkUserConfigQO;
import com.dianxin.smartpark.service.common.SmartParkUserConfigService;
import com.dianxin.smartpark.service.vo.common.DevicePullDataVo;
import com.dianxin.smartpark.service.vo.common.SmartParkUserCardVO;
import com.dianxin.smartpark.service.vo.common.SmartParkUserConfigVO;
import com.dianxin.smartpark.service.vo.common.SmartParkUserTzVO;
import com.dianxin.sso.client.annotation.RecordLog;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 用户凭证
 * 
 * @author chenjiasong
 * @date 2021-08-10
 */
@RestController
@RequestMapping("/smartpark/config")
public class SmartParkUserConfigController
{
    @Resource
    private SmartParkUserConfigService smartParkUserConfigService;

    /**
     * 查询用户信息
     */
    @PostMapping("/getUserDetailList")
    public CommonResponseBody<List<SmartParkUserTzVO>>  getUserDetailList(@RequestBody DevicePullDataVo vo) throws Exception {
        return smartParkUserConfigService.selectUserDetailList(vo);
    }

    /**
     * 查询用户信息
     */
    @PostMapping("/getUserDetailListTest")
    @SaCheckPermission("/smartpark/config/getUserDetailListTest")
    public CommonResponseBody<String>  getUserDetailListTest(@RequestBody DevicePullDataVo vo) throws Exception {
        return ResponseBodyWrapperUtil.successWrapper(JSON.toJSONString(smartParkUserConfigService.selectUserDetailList(vo).getData()));
    }


    /**
     * 查询用户card信息
     */
    @PostMapping("/getUserCardDetailList")
    public CommonResponseBody<List<SmartParkUserCardVO>>  selectUserCardDetailList(@RequestBody DevicePullDataVo vo) throws Exception {
        return smartParkUserConfigService.selectUserCardDetailList(vo);
    }

    /**
     * card查询设备用户信息
     */
    @PostMapping("/getUserCardDetailListByCardNum")
    public CommonResponseBody<SmartParkUserCardVO>  selectUserCardDetailListByCard(@RequestBody DevicePullDataVo vo) throws Exception {
        return smartParkUserConfigService.selectUserCardDetailListByCard(vo);
    }

    /**
     * 查询用户凭证列表
     */
    @PostMapping("/list")
    @SaCheckPermission("/smartpark/config/list")
    public CommonResponseBody<List<SmartParkUserConfigVO>>  list(@RequestBody SmartParkUserConfigQO qo)
    {
        return smartParkUserConfigService.selectSmartParkUserConfigList(qo);
    }


    /**
     * 获取用户凭证详细信息
     */
    @GetMapping(value = "/getInfo")
    @SaCheckPermission("/smartpark/config/getInfo")
    public CommonResponseBody<SmartParkUserConfigVO> getInfo(SmartParkUserConfigQO qo)
    {
        return smartParkUserConfigService.selectSmartParkUserConfig(qo);
    }

    /**
     * 新增用户凭证
     */
    @PostMapping("/add")
    @SaCheckPermission("/smartpark/config/add")
    public  CommonResponseBody<Boolean> add(@RequestBody SmartParkUserConfigVO vo)throws Exception
    {
        return smartParkUserConfigService.insertSmartParkUserConfig(vo);
    }

    /**
     * 修改用户凭证
     */
    @PostMapping("/edit")
    @SaCheckPermission("/smartpark/config/edit")
    @RecordLog(name = "修改用户凭证")
    public  CommonResponseBody<Boolean> edit(@RequestBody SmartParkUserConfigVO vo) throws Exception {
        return smartParkUserConfigService.updateSmartParkUserConfig(vo);
    }

    /**
     * 删除用户凭证
     */
	@DeleteMapping("/remove")
    @SaCheckPermission("/smartpark/config/remove")
    public  CommonResponseBody<Boolean> remove(@RequestBody SmartParkUserConfigVO vo)
    {
        return smartParkUserConfigService.deleteSmartParkUserConfig(vo);
    }


}
